package cate.game.friend.aid;

import cate.game.role.Role;
import cate.game.role.bag.hero.Hero;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;

@NoteClass("援助英雄数据")
public class ServerRoleAidHero {
    @NoteField("玩家uid")
    public String roleUid;
    @NoteField("援助英雄数据")
    public List<Hero> heros;
    @NoteField("援助次数")
    public int aidTimes;

    public ServerRoleAidHero(){

    }

    public ServerRoleAidHero(Role role) {
        this.roleUid = role.getUid();
        this.heros = new ArrayList<>();
    }

    public void add(Hero hero) {
        heros.add(hero.copy());
    }

    public int heroSize(){
        return heros.size();
    }

    public boolean containsHero(String heroUid) {
        return heros.stream().anyMatch(e -> StringUtils.equals(e.uid, heroUid));
    }

    public Hero findHero(String heroUid) {
        return heros.stream().filter(e -> StringUtils.equals(e.uid, heroUid)).findAny().orElse(null);
    }

    public int successAid() {
        return ++aidTimes;
    }
}
